home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gxbitfmt.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  7.4 KB  |  208 lines

  1. /* Copyright (C) 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gxbitfmt.h,v 1.2 2000/09/19 19:00:33 lpd Exp $ */
  20. /* Definitions for bitmap storage formats */
  21.  
  22. #ifndef gxbitfmt_INCLUDED
  23. #  define gxbitfmt_INCLUDED
  24.  
  25. /*
  26.  * Several operations, such as the get_bits_rectangle driver procedure, can
  27.  * take and/or produce data in a flexible variety of formats; the ability to
  28.  * describe how bitmap data is stored is useful in other contexts as well.
  29.  * We define bitmap storage formats using a bit mask: this allows a
  30.  * procedure to ask for, or offer to provide, data in more than one format.
  31.  */
  32.  
  33. typedef ulong gx_bitmap_format_t;
  34.  
  35.     /*
  36.      * Define the supported color space alternatives.
  37.      */
  38.  
  39. #define GB_COLORS_NATIVE (1L<<0)  /* native representation (DevicePixel) */
  40. #define GB_COLORS_GRAY   (1L<<1)  /* DeviceGray */
  41. #define GB_COLORS_RGB    (1L<<2)  /* DeviceRGB */
  42. #define GB_COLORS_CMYK   (1L<<3)  /* DeviceCMYK */
  43.  
  44. #define GB_COLORS_STANDARD_ALL\
  45.   (GB_COLORS_GRAY | GB_COLORS_RGB | GB_COLORS_CMYK)
  46. #define GB_COLORS_ALL\
  47.   (GB_COLORS_NATIVE | GB_COLORS_STANDARD_ALL)
  48. #define gb_colors_for_device(dev)\
  49.   ((dev)->color_info.num_components == 4 ? GB_COLORS_CMYK :\
  50.    (dev)->color_info.num_components == 3 ? GB_COLORS_RGB : GB_COLORS_GRAY)
  51. #define GB_COLORS_NAMES\
  52.   "colors_native", "colors_Gray", "colors_RGB", "colors_CMYK"
  53.  
  54.     /*
  55.      * Define whether alpha information is included.  For GB_COLORS_NATIVE,
  56.      * all values other than GB_ALPHA_NONE are equivalent.
  57.      */
  58.  
  59. #define GB_ALPHA_NONE  (1L<<4)  /* no alpha */
  60. #define GB_ALPHA_FIRST (1L<<5)  /* include alpha as first component */
  61. #define GB_ALPHA_LAST  (1L<<6)  /* include alpha as last component */
  62.   /*unused*/           /*(1L<<7)*/
  63.  
  64. #define GB_ALPHA_ALL\
  65.   (GB_ALPHA_NONE | GB_ALPHA_FIRST | GB_ALPHA_LAST)
  66. #define GB_ALPHA_NAMES\
  67.   "alpha_none", "alpha_first", "alpha_last", "?alpha_unused?"
  68.  
  69.     /*
  70.      * Define the supported depths per component for GB_COLORS_STANDARD.
  71.      * For GB_COLORS_NATIVE with planar packing, it is the client's
  72.      * responsibility to know how the device divides up the bits of the
  73.      * pixel.
  74.      */
  75.  
  76. #define GB_DEPTH_1  (1L<<8)
  77. #define GB_DEPTH_2  (1L<<9)
  78. #define GB_DEPTH_4  (1L<<10)
  79. #define GB_DEPTH_8  (1L<<11)
  80. #define GB_DEPTH_12 (1L<<12)
  81. #define GB_DEPTH_16 (1L<<13)
  82.   /*unused1*/       /*(1L<<14)*/
  83.   /*unused2*/       /*(1L<<15)*/
  84.  
  85. #define GB_DEPTH_ALL\
  86.   (GB_DEPTH_1 | GB_DEPTH_2 | GB_DEPTH_4 | GB_DEPTH_8 |\
  87.    GB_DEPTH_12 | GB_DEPTH_16)
  88. #define GB_DEPTH_NAMES\
  89.   "depth_1", "depth_2", "depth_4", "depth_8",\
  90.   "depth_12", "depth_16", "?depth_unused1?", "?depth_unused2?"
  91.  
  92. /* Find the maximum depth of an options mask. */
  93. #define GB_OPTIONS_MAX_DEPTH(opt)\
  94. "\
  95. \000\001\002\002\004\004\004\004\010\010\010\010\010\010\010\010\
  96. \014\014\014\014\014\014\014\014\014\014\014\014\014\014\014\014\
  97. \020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\
  98. \020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\
  99. "[((opt) >> 8) & 0x3f]
  100. /* Find the depth of an options mask with exactly 1 bit set. */
  101. #define GB_OPTIONS_DEPTH(opt)\
  102.   ((((opt) >> 8) & 0xf) |\
  103.    "\000\000\014\020"[((opt) >> 12) & 3])
  104.  
  105.     /*
  106.      * Define the supported packing formats.  Currently, GB_PACKING_PLANAR is
  107.      * only partially supported, and GB_PACKING_BIT_PLANAR is hardly supported
  108.      * at all.
  109.      */
  110.  
  111. #define GB_PACKING_CHUNKY     (1L<<16)
  112. #define GB_PACKING_PLANAR     (1L<<17)  /* 1 plane per component */
  113. #define GB_PACKING_BIT_PLANAR (1L<<18)  /* 1 plane per bit */
  114.  
  115. #define GB_PACKING_ALL\
  116.   (GB_PACKING_CHUNKY | GB_PACKING_PLANAR | GB_PACKING_BIT_PLANAR)
  117. #define GB_PACKING_NAMES\
  118.   "packing_chunky", "packing_planar", "packing_bit_planar"
  119.  
  120.     /*
  121.      * Define whether to return a subset of the planes.  With planar packing
  122.      * formats, if this is set, only those planes that had non-zero data
  123.      * pointers originally will be returned (either by copying or by
  124.      * pointer).  With chunky packing, if this is set, only an undefined
  125.      * subset of the returned bits may be valid.
  126.      */
  127.  
  128. #define GB_SELECT_PLANES  (1L<<19)
  129. #define GB_SELECT_ALL\
  130.   (GB_SELECT_PLANES)
  131. #define GB_SELECT_NAMES\
  132.   "select_planes"
  133.  
  134.     /*
  135.      * Define the possible methods of returning data.
  136.      */
  137.  
  138. #define GB_RETURN_COPY    (1L<<20)  /* copy to client's buffer */
  139. #define GB_RETURN_POINTER (1L<<21)  /* return pointers to data */
  140.  
  141. #define GB_RETURN_ALL\
  142.   (GB_RETURN_COPY | GB_RETURN_POINTER)
  143. #define GB_RETURN_NAMES\
  144.   "return_copy", "return_pointer"
  145.  
  146.     /*
  147.      * Define the allowable alignments.  This is only relevant for
  148.      * GB_RETURN_POINTER: for GB_RETURN_COPY, any alignment is
  149.      * acceptable.
  150.      */
  151.  
  152. #define GB_ALIGN_STANDARD (1L<<22)  /* require standard bitmap alignment */
  153. #define GB_ALIGN_ANY      (1L<<23)  /* any alignment is acceptable */
  154.  
  155. #define GB_ALIGN_ALL\
  156.   (GB_ALIGN_ANY | GB_ALIGN_STANDARD)
  157. #define GB_ALIGN_NAMES\
  158.   "align_standard", "align_any"
  159.  
  160.     /*
  161.      * Define the allowable X offsets.  GB_OFFSET_ANY is only relevant for
  162.      * GB_RETURN_POINTER: for GB_RETURN_COPY, clients must specify
  163.      * the offset so they know how much space to allocate.
  164.      */
  165.  
  166. #define GB_OFFSET_0         (1L<<24)  /* no offsetting */
  167. #define GB_OFFSET_SPECIFIED (1L<<25)  /* client-specified offset */
  168. #define GB_OFFSET_ANY       (1L<<26)  /* any offset is acceptable */
  169.                 /* (for GB_RETURN_POINTER only) */
  170.   /*unused*/                /*(1L<<27)*/
  171.  
  172. #define GB_OFFSET_ALL\
  173.   (GB_OFFSET_0 | GB_OFFSET_SPECIFIED | GB_OFFSET_ANY)
  174. #define GB_OFFSET_NAMES\
  175.   "offset_0", "offset_specified", "offset_any", "?offset_unused?"
  176.  
  177.     /*
  178.      * Define the allowable rasters.  GB_RASTER_ANY is only relevant for
  179.      * GB_RETURN_POINTER, for the same reason as GB_OFFSET_ANY.
  180.      * Note also that if GB_ALIGN_STANDARD and GB_RASTER_SPECIFIED are
  181.      * both chosen and more than one scan line is being transferred,
  182.      * the raster value must also be aligned (i.e., 0 mod align_bitmap_mod).
  183.      * Implementors are not required to check this.
  184.      */
  185.  
  186.     /*
  187.      * Standard raster is bitmap_raster(dev->width) for return_ptr,
  188.      * bitmap_raster(x_offset + width) for return_copy,
  189.      * padding per alignment.
  190.      */
  191. #define GB_RASTER_STANDARD  (1L<<28)
  192. #define GB_RASTER_SPECIFIED (1L<<29)  /* any client-specified raster */
  193. #define GB_RASTER_ANY       (1L<<30)  /* any raster is acceptable (for */
  194.                 /* GB_RETURN_POINTER only) */
  195.  
  196. #define GB_RASTER_ALL\
  197.   (GB_RASTER_STANDARD | GB_RASTER_SPECIFIED | GB_RASTER_ANY)
  198. #define GB_RASTER_NAMES\
  199.   "raster_standard", "raster_specified", "raster_any"
  200.  
  201. /* Define names for debugging printout. */
  202. #define GX_BITMAP_FORMAT_NAMES\
  203.   GB_COLORS_NAMES, GB_ALPHA_NAMES, GB_DEPTH_NAMES, GB_PACKING_NAMES,\
  204.   GB_SELECT_NAMES, GB_RETURN_NAMES, GB_ALIGN_NAMES, GB_OFFSET_NAMES,\
  205.   GB_RASTER_NAMES
  206.  
  207. #endif /* gxbitfmt_INCLUDED */
  208.